package itheima.C01_io_char_reader;

import java.io.*;

public class Test {
    public static void main(String[] args) throws IOException {
        long start=System.currentTimeMillis();
        BufferedInputStream bis= null;
        BufferedOutputStream bos= null;
        try {
            FileInputStream fis=new FileInputStream("H:\\javabase_ws2\\java_advance\\Day11_io\\src\\itheima\\C01_io_char_reader\\y.txt");
            FileOutputStream fos=new FileOutputStream("H:\\javabase_ws2\\java_advance\\Day11_io\\src\\itheima\\C01_io_char_reader\\z.txt");

            bis = new BufferedInputStream(fis);
            bos = new BufferedOutputStream(fos);
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
        byte[]b=new byte[1024];
        int len=-1;
        while ((len = bis.read(b)) != -1) {
            bos.write(b,0,len);
            System.out.println("拷贝完毕！");
            long end=System.currentTimeMillis();
            System.out.println("拷贝耗时："+(end-start)+"ms");
       /* try {
            FileReader fr = new FileReader("H:\\javabase_ws2\\java_advance\\Day11_io\\src\\itheima\\C01_io_char_reader\\y.txt");*/
/*      //2.调用FileReader对象，读取文件中的字符数据
        //·次读取个字行：10的次数多，频繁进行10操作，效丰候
            int rs;
        while ((rs = fr.read()) != -1) {
            System.out.println("读取的字符数据"+(char) rs);
        }*/
            //每次读取多个字符：减少io的次数（需要操作系统的支持），提高效车
/*
            char[]chs=new char[2];
            int len=-1;
            while ((len = fr.read(chs)) != -1) {
                System.out.println("读取的字符数据"+new String(chs,0,len));
            }
        } catch (IOException e) {
            throw new RuntimeException(e);*/
        }
    }
}
